<?php

namespace App\Models;


use App\Http\Traits\GlobalConstant;

class TeamUser extends Orm
{
    //

    protected $table = 'team_user';
    protected $dateFormat = 'U';
    public $timestamps = true;


    public function teamInfo()
    {
        return $this->belongsTo(Team::class, 'team_id');
    }

    public function userInfo()
    {
        return $this->belongsTo(Users::class, 'user_id');
    }

    public function getIsCaptainAttribute()
    {
        return GlobalConstant::getTeamRoleMap($this->attributes['is_captain']);
    }

    public function projectInfo()
    {
        return $this->belongsTo(Project::class, 'project_id');
    }

    public function sweepInfo()
    {
        return $this->hasMany(Sweep::class, 'project_id', 'project_id');
    }

}
